import { defHttp } from '@/utils/http/axios';
import { ErrorMessageMode } from '#/axios';
import { BaseResponse, PagerResponse } from '@/api/base';

// 定义接口地址
enum Api {
  /** 批量删除 */
  BATCH_DELETE = '/exam/examAnswerSheet/batchDelete',
  /** 删除 */
  DELETE_BY_ID = '/exam/examAnswerSheet/delete/',
  /** 查询基本信息 */
  DETAIL = '/exam/examAnswerSheet/',
  /** 列表查询 */
  LIST = '/exam/examAnswerSheet/list',
  /** 分页查询 */
  PAGER = '/exam/examAnswerSheet/pager',
  /** 新增 */
  SAVE = '/exam/examAnswerSheet/save',
  /** 修改 */
  UPDATE = '/exam/examAnswerSheet/update/',
}

// 定义参数类型

export interface ExamAnswerSheetDO {
  id?: number;
  creator?: String;
  createTime?: Date;
  updater?: String;
  updateTime?: Date;
  examId?: number;
  questionId?: number;
  answer?: String;
  standardAnswer?: String;
  costTime?: number;
  costTimeDesc?: String;
  correct?: number;
}

export interface ExamAnswerSheetQuery {
  id?: number;
  creator?: String;
  createTime?: Date;
  updater?: String;
  updateTime?: Date;
  examId?: number;
  questionId?: number;
  answer?: String;
  standardAnswer?: String;
  costTime?: number;
  costTimeDesc?: String;
  correct?: number;
}

export interface ExamAnswerSheetRequest {
  id?: number;
  creator?: String;
  createTime?: Date;
  updater?: String;
  updateTime?: Date;
  examId?: number;
  questionId?: number;
  answer?: String;
  standardAnswer?: String;
  costTime?: number;
  costTimeDesc?: String;
  correct?: number;
}

// 定义接口方法: save
// 批量删除
export function batchDelete(params: number[], mode: ErrorMessageMode = 'message') {
  return defHttp.post<BaseResponse<number>>(
    {
      url: Api.BATCH_DELETE,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}
// 删除
export function deleteById(id: number, mode: ErrorMessageMode = 'message') {
  return defHttp.delete<BaseResponse<boolean>>(
    {
      url: Api.DELETE_BY_ID + '/' + id,
    },
    {
      errorMessageMode: mode,
    },
  );
}
// 查询基本信息
export function detail(id: number, mode: ErrorMessageMode = 'message') {
  return defHttp.get<BaseResponse<ExamAnswerSheetDO>>(
    {
      url: Api.DETAIL + '/' + id,
    },
    {
      errorMessageMode: mode,
    },
  );
}
// 列表查询
export function list(params: ExamAnswerSheetQuery, mode: ErrorMessageMode = 'message') {
  return defHttp.post<BaseResponse<Array<ExamAnswerSheetDO>>>(
    {
      url: Api.LIST,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}
// 分页查询
export function pager(params: ExamAnswerSheetQuery, mode: ErrorMessageMode = 'message') {
  return defHttp.post<BaseResponse<PagerResponse<ExamAnswerSheetDO>>>(
    {
      url: Api.PAGER,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}
// 新增
export function save(params: ExamAnswerSheetRequest, mode: ErrorMessageMode = 'message') {
  return defHttp.post<BaseResponse<number>>(
    {
      url: Api.SAVE,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}
// 修改
export function update(id: number, params: ExamAnswerSheetRequest, mode: ErrorMessageMode = 'message') {
  return defHttp.put<BaseResponse<boolean>>(
    {
      url: Api.UPDATE + '/' + id,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

